package com.ansion.commonchat.contact.sync;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

import com.ansion.constant.BConstant;
import com.ansion.utils.CocoLocalBroadcastUtil;


public class SyncContactsManager {
	
		private static final String TAG = "SyncContactsManager";


		private static SyncContactsManager manager;


		private SyncContactsManager() {
			
		}

		public void registerContactsChange() {
			SyncContactsReceiver receiver = new SyncContactsReceiver();

			IntentFilter filter = new IntentFilter();
			filter.addAction(BConstant.Contact.ACTION_LOADCONTACTS_END);
			CocoLocalBroadcastUtil.registerLocalBroadCast(receiver, filter);
		}

		class SyncContactsReceiver extends BroadcastReceiver {

			@Override
			public void onReceive(Context context, Intent intent) {
				startSyncContactsThread();
			}

		}

		public static synchronized SyncContactsManager getInstance() {

			if (null == manager) {
				synchronized (SyncContactsManager.class) {
					if (null == manager) {
						manager = new SyncContactsManager();
					}
				}
			}
			return manager;
		}
		
		public void startSyncContactsThread() {
			SyncContactsThread.getInstance().startQuery();
		}

}
